package com.mask.mr.number;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class NumReducer extends Reducer<Text, IntWritable, Text, LongWritable> {
    protected void reduce(Text key,Iterable<IntWritable> values,
                          Reducer<Text, IntWritable, Text, LongWritable>.Context context) throws IOException, InterruptedException {
        long count = 0;
        for(IntWritable v:values) {
            count += v.get();
        }
        context.write(key, new LongWritable(count));
    }
}